FROM alpine:latest

MAINTAINER xiongjunfeng@haocang.com

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
  && apk add --no-cache bash rsyslog logrotate shadow tar gzip sudo \
  && rm /etc/periodic/daily/logrotate \
  && groupadd -r -g 10000 syslog \
  && useradd --no-log-init -r -g 10000 -u 10000 syslog

COPY ./conf/start.sh /usr/local/bin/
COPY ./conf/rsyslog.conf /etc/rsyslog.conf
COPY ./conf/rsyslog_docker.conf /etc/rsyslog.d/rsyslog_docker.conf

COPY ./conf/logrotate /etc/periodic/hourly/logrotate
COPY ./conf/logrotate.conf /etc/logrotate.d/logrotate.conf

RUN chmod +x /usr/local/bin/start.sh /etc/rsyslog.d/ \
  && chown -R 10000:10000 /etc/rsyslog.conf /etc/rsyslog.d/ /run

# RUN chage -M 99999 root

HEALTHCHECK CMD netstat -ltun | grep 10514

VOLUME /var/log/docker/ /run/ /etc/logrotate.d/

EXPOSE 10514

CMD /usr/local/bin/start.sh
